package com.reflect;

/**
 * 反射demo类型
 * ReflectDemo.java
 * 2018年4月17日 上午9:17:46
 * @author yaojinshan
 */
public class ReflectDemo {
	/**
	 * 数据数组
	 */
	public final static Object[] dataArray = new Object[]{"中国","日本",1,25l};

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		User user = new User();
		// 强制泛型对象必须为User类型
		//声明泛型的对象 并制定成员变量user
		Entity<User> ue = new Entity<User>(user);
		for (int i = 0; i < dataArray.length; i++) {
			ue.fillData(dataArray[i], User.class.getDeclaredFields()[i], Entity.METHOD_PRRFIX_SET);
		}
		System.out.println(user.toString());
		//只声明泛型的对象 
		Entity2<User> ue2 = new Entity2<User>();
		User user2 = new User();
		for (int i = 0; i < dataArray.length; i++) {
			ue2.fillData(user2,dataArray[i], User.class.getDeclaredFields()[i], Entity.METHOD_PRRFIX_SET);
		}
		System.out.println(user2.toString());
	}
}
